from django.contrib import admin

from prj003.models import (
    questionnaire, summary, history, status,
    relevant, clinical, cure, results
)

from prj003.utils import samecode


@admin.register(questionnaire.QuestionNaire)
class QuestionNaireAdmin(admin.ModelAdmin):
    list_display = ('serial', 'patient_name', 'check_status', 'create_time', 'owner')

    def save_model(self, request, obj, form, change):
        obj.save()


@admin.register(summary.Summary)
class SummaryAdmin(admin.ModelAdmin, samecode.SameCodeAdmin):
    list_display = ('id', 'zhusu', 'create_time', 'owner_link', 'questionnaire_link', )

    def save_model(self, request, obj, form, change):
        obj.save()


@admin.register(history.History)
class HistoryAdmin(admin.ModelAdmin, samecode.SameCodeAdmin):
    list_display = ('id', 'has_history', 'create_time', 'owner_link', 'questionnaire_link', )

    def save_model(self, request, obj, form, change):
        obj.save()


@admin.register(relevant.Relevant)
class RelevantAdmin(admin.ModelAdmin, samecode.SameCodeAdmin):
    list_display = ('id', 'body_check_wu', 'create_time', 'owner_link', 'questionnaire_link',)


@admin.register(clinical.Clinical)
class ClinicalAdmin(admin.ModelAdmin, samecode.SameCodeAdmin):
    list_display = ('id', 'zhong_tongjing', 'create_time', 'owner_link', 'questionnaire_link')


@admin.register(cure.Cure)
class CureAdmin(admin.ModelAdmin, samecode.SameCodeAdmin):
    list_display = ('id', 'is_together_cure', 'create_time', 'owner_link', 'questionnaire_link')


@admin.register(results.Results)
class ResultsAdmin(admin.ModelAdmin, samecode.SameCodeAdmin):
    list_display = ('id', 'vas', 'create_time', 'owner_link', 'questionnaire_link')


@admin.register(status.InfoStatus)
class InfoStatusAdmin(admin.ModelAdmin):
    list_display = ('id', 'info_serial', 'fix_name_chinese', 'fix_before', 'fix_after')
    search_fields = ['id', ]
    list_filter = ['id', ]
